<template>
  <div>
    <div style="text-align:left">
      患者信息：
      <el-tag >姓名：{{patient.realName}}</el-tag>
      <el-tag >病历号：{{patient.caseNumber}}</el-tag>
      <el-tag >年龄：{{patient.age}}</el-tag>
      <el-tag >性别：{{patient.gender}}</el-tag>
    </div>
    <el-divider></el-divider>
    <div style="font-size:20px;text-align:left">
      <i class="el-icon-document-checked">在诊患者</i>
    </div>
    <el-divider></el-divider>
    <el-row :gutter="20">
      <el-col :span="6"><el-input v-model="caseNumber" placeholder="请输入患者病历号"></el-input></el-col>
      <el-col :span="6"><el-input v-model="realName" placeholder="请输入患者姓名"></el-input></el-col>
      <el-col :span="2"><el-button @click="selectpatients">搜索</el-button></el-col>
<!--      <el-col :span="10"> <el-input/></el-col>-->
    </el-row>
    <el-table :data="now_all_patient" style="margin-top:10px">
      <el-table-column type="index" label="编号" width="50"></el-table-column>
      <el-table-column prop="caseNumber" label="患者病历号" width="150"></el-table-column>
      <el-table-column prop="realName" label="患者姓名" width="150"></el-table-column>
      <el-table-column prop="cardNumber" label="患者身份证" ></el-table-column>
      <el-table-column prop="visitState" label="患者状态" width="120"></el-table-column>
      <el-table-column prop="visitDate" label="挂号时间" width="260"></el-table-column>
      <el-table-column label="操作" width="120">
        <template #default="scope" >
          <el-button size="mini" @click="toUpdateMedicalRecord(scope.row)">更新病历</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div style="width:80%;margin-top:10px;text-align:right">
    <el-pagination
        default-current-page="currPage"
        :total="totalCount"
        layout="prev,pager,next"
        :page-size="pageSize"
        @current-change="nowAllPatientPageChange" >
    </el-pagination>
    </div>

  </div>
</template>
<script>
import qs from 'qs';
import {getSessionLoginUser} from '../../util/util'
import {isNullMessage} from "../../util/util"
import {setSessionStorage} from "@/util/common";
import {ElMessage} from "element-plus";
export default{
  data(){
    return{
      //当前页
      currPage:1,
      // finish_check_patient:[],

      caseNumber:"",
      realName:"",


      patient:{
        realName:'',
        caseNumber:'',
        age:"",
        gender:''
      },
      //查询到的患者
      now_all_patient:[],
      totalCount:0,
      pageSize:5,
    }
  },
  methods:{

    //更新病历(给session赋值)
    toUpdateMedicalRecord:function (row)
    {
      console.log(row)
      this.patient=row
      setSessionStorage("patient",row)
      ElMessage({
        type:'success',
        message:'更新病历成功'
      })
    },
    //分组组件页码改变时的事件对应的函数
    nowAllPatientPageChange:function (currPage){
      this.currPage=currPage
    },
//得到患者
    selectpatients:function ()
    {

      let url=`http://localhost:8092/register/selectpatients/${this.currPage}`
      let value={
        caseNumber:this.caseNumber,
        realName:this.realName
      }
      this.$axios.post(url,value).then(resp=>{

        this.now_all_patient=resp.data.result

        this.totalCount=resp.data.total

        //this.getPatientMedicaltechnology()

      })
    },

  },
  mounted() {
  }

}

</script>